<!--<form class="tableform" method='post' action='index.php?app=b2c&ctl=admin_order&act=batch_confirm_business'>-->
<div class="division">
	<table cellpadding="0" cellspacing="0" class="gridlist">
		<col style="width:30%"></col>
		<col style="width:30%"></col>
		<col style="width:40%"></col>
		<thead>
		<tr>
			<th><{t}>供应商<{/t}></th>
			<th><{t}>最早订单时间<{/t}></th>
			<th><{t}>操作<{/t}></th>
			<th><{t}><input class="checkall" type="checkbox" name="checkall"   value="" ><{/t}></th>
		</tr>
		</thead>
		<tbody>
		<{foreach from=$info item=item}>
		<{if $item.status != 1}>
		<tr>
			<input type="hidden" name="order_id" value="<{$item.mainOrder_id}>">
			<input type="hidden" class="business_id" name="business_id[]" value="<{$item.business_id}>">
			<td><{$item.english_all_name}></td>
			<td><{$item.first_createtime|cdate}></td>
			<td>
				<a href="index.php?app=b2c&ctl=admin_order&act=to_split&order_id=<{$item.mainOrder_id}>&business_id=<{$item.business_id}>" target="dialog::{title:'<{t}>确认库存<{/t}>', width:1200, height:500}"><{t}>确认库存<{/t}></a>
			</td>
			<td><input class="check_box" type="checkbox" name="checkbox[]"  value="<{$item.business_id}>" ></td>
		</tr>
		<{/if}>
		<{/foreach}>
		</tbody>
	</table>
</div>
<div class="table-action">
	<{button type="button"  label=$___b2c="确定"|t:'b2c'}>
</div>
<!--</form>-->




<script>
	jQuery('.check_box').prop("checked",true);
	jQuery('.checkall').prop("checked",true);
	jQuery('.checkall').click(function(){
		if(jQuery(this).prop("checked")){
			jQuery('.check_box').each(
					function(){
						jQuery(this).prop("checked",true);
					}
			);
		}else{
			jQuery('.check_box').each(
					function(){
						jQuery(this).prop("checked",false);
					}
			);
		}
	});
	jQuery('.check_box').click(function(){
		var keynum =0;
		jQuery('.check_box').each(function(){
			if(jQuery(this).prop('checked')==false){
				keynum++;
			}
			if(keynum>0){
				jQuery('.checkall').prop("checked",false);
			}else{
				jQuery('.checkall').prop("checked",true);
			}

		});
	});

	jQuery('.table-action button').click(function(){
		var iftrue="0";
		jQuery('.check_box').each(function(){
			if(jQuery(this).prop("checked")==false){
				iftrue=1;
			}
		});
		var business_id  = "";
		jQuery('.check_box').each(function(){
			if(jQuery(this).prop("checked")==true){
				jQuery(this).parents("tr").find(".business_id").each(function(){
						business_id+= jQuery(this).val()+",";
				});
			}
		});
		business_id = business_id.substring(0,business_id.length-1);
		var order_id =jQuery("input[name='order_id']").val();
		jQuery.ajax({
    	type: "POST",
    	url: '<{link app=b2c ctl=admin_order act=batch_confirm_business}>',
    	data:{'order_id':order_id,'business_id':business_id},
    	dataType: 'JSON',
    	success: function(data) {

    		//console.log(iftrue);
    		if(iftrue=="0"){
    			    //关闭_blank页面，同时刷新父级页面
    				window.close();
    				window.opener.document.location.reload();
    		}else{
    			jQuery.each(data['data'],function(e,i) {
                jQuery('.business_id').each(function(){
                		if(jQuery(this).val()==i){
                			jQuery(this).parents('tr').remove();
                		}
                });
            });
    		}
    	}
  	});
	});


</script>